package com.webmeeting.jsfbeans.chat.wordchat;

import javax.faces.bean.ManagedBean;
import javax.faces.bean.RequestScoped;
import javax.faces.context.FacesContext;
import javax.servlet.http.HttpSession;

import com.webmeeting.chat.wordchat.dao.entities.User;

@ManagedBean(name = "chatRoomBean_wordchat")
@RequestScoped
public class ChatRoomBean {

	// Current user stored in session
	private User		user;
	// header message
	private String	headerMsg;

	public User getUser() {
		FacesContext fc = FacesContext.getCurrentInstance();
		HttpSession session = (HttpSession) fc.getExternalContext().getSession(true);
		User currUser = (User) session.getAttribute("user");
		this.user = currUser;
		return user;
	}

	public void setUser(User user) {
		FacesContext fc = FacesContext.getCurrentInstance();
		HttpSession session = (HttpSession) fc.getExternalContext().getSession(true);
		User currUser = (User) session.getAttribute("user");
		this.user = currUser;
	}

	public String getHeaderMsg() {
		return headerMsg;
	}

	public void setHeaderMsg(String headerMsg) {
		this.headerMsg = headerMsg;
	}

}
